package _go

func levelOrder(root *TreeNode) []int {

	if root == nil {
		return []int{}
	}

	var tmp []*TreeNode

	tmp = append(tmp, root)
	var res []int
	for i := 0; i < len(tmp); i++ {
		res = append(res, tmp[i].Val)

		if tmp[i].Left != nil {
			tmp = append(tmp, tmp[i].Left)
		}
		if tmp[i].Right != nil {
			tmp = append(tmp, tmp[i].Right)
		}
	}
	return res
}
